Telegram Group & Telegram Channel
7. Program to Calculate Area's.

import java.util.Scanner;

class AreaCalculator
{

float l, b, h, r, ba, s, c;
float result = 0f;
float pi = 3.14f;
int var;
public static void main(String[] args)
{
AreaCalculator ar = new AreaCalculator();
ar.options();
}

public void options()
{
Scanner a = new Scanner(System.in);
System.out.println("Enter the Object of which Area is to be calculated \n1:square \n2:rectangle \n3:Triangle\n4:circle\n5:Trapezoid\n6:Repeat\n7:Exit");

var = a.nextInt();
Area a1 = new Area();

if (var == 1)
{
System.out.println("Enter the Side of Square");
s = a.nextFloat();
a1.square(s);
options();
}

else if (var == 2)
{
System.out.println("Enter the Length of Rectangle");
l = a.nextFloat();
System.out.println("Enter the Breadth of Rectangle");
b = a.nextFloat();
a1.rectangle(l, b);
options();
}

else if (var == 3)
{
System.out.println("Enter the Height of Triangle");
h = a.nextFloat();
System.out.println("Enter the Base of Triangle");
ba = a.nextFloat();
a1.triangle(h, ba);
options();
}

else if (var == 4)
{
System.out.println("Enter the Radius of Circle");
r = a.nextFloat();
a1.circle(r);
options();
}

else if (var == 5)
{
System.out.println("Enter the A side of Trapezoid");
b = a.nextFloat();
System.out.println("Enter the B side of Trapezoid");
c = a.nextFloat();
System.out.println("Enter the Height of Trapezoid");
h = a.nextFloat();
a1.trapezoid(b, c, h);
options();
}
}
}

class Area
{
public void square(float s)
{
float result = 0f;
result = s * s;
System.out.println("The Area of Square is :" + result);
}

public void rectangle(float l, float b)
{
float result = 0f;
result = l * b;
System.out.println("The Area of Rectangle is :" + result);
}

public void triangle(float h, float ba)
{
float result = 0f;
result = 0.5f * h * ba;
System.out.println("The Area of Triangle is :" + result);
}

public void circle(float r)
{
float result = 0f;
result = 3.14f * (r * r);
System.out.println("The Area of Circle is :" + result);
}

public void trapezoid(float b, float c, float h)
{
float result = 0f;
result = (((b + c) / 2) * h);
System.out.println("The Area of Trapezoid is :" + result);
}
}

@java_codings



tg-me.com/java_codings/11
Create:
Last Update:

7. Program to Calculate Area's.

import java.util.Scanner;

class AreaCalculator
{

float l, b, h, r, ba, s, c;
float result = 0f;
float pi = 3.14f;
int var;
public static void main(String[] args)
{
AreaCalculator ar = new AreaCalculator();
ar.options();
}

public void options()
{
Scanner a = new Scanner(System.in);
System.out.println("Enter the Object of which Area is to be calculated \n1:square \n2:rectangle \n3:Triangle\n4:circle\n5:Trapezoid\n6:Repeat\n7:Exit");

var = a.nextInt();
Area a1 = new Area();

if (var == 1)
{
System.out.println("Enter the Side of Square");
s = a.nextFloat();
a1.square(s);
options();
}

else if (var == 2)
{
System.out.println("Enter the Length of Rectangle");
l = a.nextFloat();
System.out.println("Enter the Breadth of Rectangle");
b = a.nextFloat();
a1.rectangle(l, b);
options();
}

else if (var == 3)
{
System.out.println("Enter the Height of Triangle");
h = a.nextFloat();
System.out.println("Enter the Base of Triangle");
ba = a.nextFloat();
a1.triangle(h, ba);
options();
}

else if (var == 4)
{
System.out.println("Enter the Radius of Circle");
r = a.nextFloat();
a1.circle(r);
options();
}

else if (var == 5)
{
System.out.println("Enter the A side of Trapezoid");
b = a.nextFloat();
System.out.println("Enter the B side of Trapezoid");
c = a.nextFloat();
System.out.println("Enter the Height of Trapezoid");
h = a.nextFloat();
a1.trapezoid(b, c, h);
options();
}
}
}

class Area
{
public void square(float s)
{
float result = 0f;
result = s * s;
System.out.println("The Area of Square is :" + result);
}

public void rectangle(float l, float b)
{
float result = 0f;
result = l * b;
System.out.println("The Area of Rectangle is :" + result);
}

public void triangle(float h, float ba)
{
float result = 0f;
result = 0.5f * h * ba;
System.out.println("The Area of Triangle is :" + result);
}

public void circle(float r)
{
float result = 0f;
result = 3.14f * (r * r);
System.out.println("The Area of Circle is :" + result);
}

public void trapezoid(float b, float c, float h)
{
float result = 0f;
result = (((b + c) / 2) * h);
System.out.println("The Area of Trapezoid is :" + result);
}
}

@java_codings

BY Advance Java πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_codings/11

View MORE
Open in Telegram


Advance Java ‍ Telegram | DID YOU KNOW?

Date: |

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. β€œThe technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. β€œUnfortunately, a U.S. court stopped TON from happening.”

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothersβ€”or maybe the next Silverado?β€”echoed through the canyons of Wall Street as investors prepared for the worst.

Advance Java ‍ from no


Telegram Advance Java πŸ‘¨β€πŸ’»
FROM USA